export const getPriceFilter = (value) => {
  if (typeof value === 'number') {
    return (value / 100).toFixed(2)
  }
  return '0.00'
}

export const countMenu = (routes, code = 'APP') => {
  return routes.filter(item => item.parentCode === code).map(n => {
    if (n.hideInRoute) {
      n.child = countMenu(routes, n.code)
    }
    return n
  })
}

export const checkPermission = (code = '', auth = []) => {
  return auth.includes(code)
}

export const dealWithLocationsearch = () => {
  let search = location.search.substr(1).split('&') // 初步处理数据-->去掉?分开多个键值对
  let obj = {}

  function dealWithkeyValue (obj, keyAndValue) {
    for (let i = 0; i < keyAndValue.length; i++) {
      let pos = keyAndValue[i].split('=')
      obj[pos[0]] = pos[1]
    } // 遍历location.search中每一个元素
  }
  dealWithkeyValue(obj, search) // 调用

  return obj // 最终返回值为对象
}
